<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      function Star(uname, age) {
        this.uname = uname;
        this.age = age;
        this.sum = function () {
          console.log(this.age);
        };
      }
      // Star.prototype.address = function () {
      //     console.log('我在台湾');
      // }
      Star.prototype = {
        /*当我们以对象的方式赋值 会覆盖掉原来的属性  
                我们需要手动 指向Star*/
        constructor: Star, //作用用来记录哪个对象引用的构造函数
        sing: function () {
          console.log("我会唱歌");
          console.log(this.age);
        },
      };
      /*他们的construct函数都会指向Star*/
      var ldh = new Star("刘德华", 15);
      var zxy = new Star("张学友", 18);
      ldh.sing();
      console.log(Star.prototype);
      console.log(ldh); //
      console.log(ldh.__proto__.constructor === Star);

      // function Super() {}

      // function Middle() {}
      // function Sub() {}

      // Middle.prototype = new Super();
      // Sub.prototype = new Middle();
      // var suber = new Sub();
      // console.log(suber);
      // console.log(Sub.prototype);
      // console.log(Sub.prototype.__proto__);
    </script>
  </body>
</html>
